import * as types from "../mutation-types";
import staffService from "../../services/staff";
// initial state
const state = {
  roleData: [],
  loginedStaff: {}
}


// getters
const getters = {}


// actions
const actions = {
  loadLoginedStaff ({commit}) {
    return new Promise((resolve, reject) => {
      staffService.loadLoginedStaff(function (data) {
        commit(types.LOAD_LOGINED_STAFF, data);
        resolve()
      });
    })

  },
  loadRole({commit}) {
    staffService.loadRoleServer(function(data){
      commit(types.LOAD_ROLE,data)
    });
  },
}


// mutations
const mutations = {
  [types.LOAD_ROLE] (state,data) {
    state.roleData=data.data
  },
  [types.LOAD_LOGINED_STAFF] (state, data) {
    state.loginedStaff = data.data;
  }
}

export default {
  state,
  getters,
  actions,
  mutations
}
